From: Andres Lagar-Cavilla Date: Thu, 1 Dec 2011 17:21:24 +0000 (+0000) Subject: x86: Add conversion from a xen map to an mfn X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=981df3dd0f3ac8431e2b97b9a7309e42a340c128;p=xen.git x86: Add conversion from a xen map to an mfn This conversion is a trivial invocation of virt_to_mfn in 64 bits. In 32 bits it uses the linear_map. Signed-off-by: Andres Lagar-Cavilla Signed-off-by: Tim Deegan Committed-by: Tim Deegan --- diff --git a/xen/arch/x86/x86_32/domain_page.c b/xen/arch/x86/x86_32/domain_page.c index 4fb563d4f0..5e12aa7941 100644 --- a/xen/arch/x86/x86_32/domain_page.c +++ b/xen/arch/x86/x86_32/domain_page.c @@ -265,3 +265,15 @@ void unmap_domain_page_global(const void *va) idx = (__va - IOREMAP_VIRT_START) >> PAGE_SHIFT; set_bit(idx, garbage); } + +/* Translate a map-domain-page'd address to the underlying MFN */ +unsigned long domain_page_map_to_mfn(void *va) +{ + l1_pgentry_t *l1e; + + ASSERT( (((unsigned long) va) >= MAPCACHE_VIRT_START) && + (((unsigned long) va) <= MAPCACHE_VIRT_END) ); + l1e = &__linear_l1_table[ + l1_linear_offset((unsigned long) va)]; + return l1e_get_pfn(*l1e); +} diff --git a/xen/include/xen/domain_page.h b/xen/include/xen/domain_page.h index 95b939ff93..a7df10b1ad 100644 --- a/xen/include/xen/domain_page.h +++ b/xen/include/xen/domain_page.h @@ -26,6 +26,12 @@ void *map_domain_page(unsigned long mfn); */ void unmap_domain_page(const void *va); + +/* + * Given a VA from map_domain_page(), return its underlying MFN. + */ +unsigned long domain_page_map_to_mfn(void *va); + /* * Similar to the above calls, except the mapping is accessible in all * address spaces (not just within the VCPU that created the mapping). Global @@ -102,6 +108,7 @@ domain_mmap_cache_destroy(struct domain_mmap_cache *cache) #define map_domain_page(mfn) mfn_to_virt(mfn) #define __map_domain_page(pg) page_to_virt(pg) #define unmap_domain_page(va) ((void)(va)) +#define domain_page_map_to_mfn(va) virt_to_mfn((unsigned long)(va)) #define map_domain_page_global(mfn) mfn_to_virt(mfn) #define __map_domain_page_global(pg) page_to_virt(pg)